#include <bits/stdc++.h>

#include <atcoder/all>
#define LL long long
using namespace std;
using namespace atcoder;

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  map<int, int> cnt[11];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    for (int j = 1, r = a[i] * 10LL % m; j < 11; j++) {
      cnt[j][r]++;
      r = r * 10LL % m;
    }
  }
  LL ans = 0;
  for (int i = 0; i < n; i++) {
    int x = a[i], len = 0;

    for (; x; x /= 10, len++);
    ans += cnt[len][(m - a[i] % m) % m];
  }
  cout << ans << "\n";
  return 0;
}
